package com.itcoon.cloud.framework.ex.exception;

import org.springframework.http.HttpStatus;

import java.io.Serializable;

/**
 * 假性异常: 处理异常结果时返回model，通常这种异常符合业务的预期情况；
 * eg: 业务中的接口符合条件成功返回的对象是A，但不符合条件要返回的对象是B, 但A和B没有任何关联，字段属性也很不一样
 */
public class PseudoException extends RuntimeException implements Serializable {

    private final Object model;
    private final HttpStatus status;
    private Throwable cause;

    public PseudoException(Object model){
        this(model, HttpStatus.OK);
    }

    public PseudoException(Object model, HttpStatus status){
        this(model, status, null);
    }

    public PseudoException(Object model, HttpStatus status, Throwable cause){
        super("PSEUDO");
        this.model = model;
        this.status = status;
        this.cause = cause;
    }

    public Object getModel() {
        return this.model;
    }

    @Override
    public Throwable getCause() {
        return this.cause;
    }

    public HttpStatus getStatus() {
        return this.status;
    }
}
